package servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.yunhe.dao.TopicDao;
import cn.yunhe.dao.impl.TopicDaoImpl;
import cn.yunhe.entity.Topic;

/**
 * Servlet implementation class PersonalCenterServlet
 */

public class PersonalCenterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PersonalCenterServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
				TopicDao topicdao=new TopicDaoImpl();
				List<Topic>list=new  ArrayList<Topic>();
				String uidStr= request.getParameter("uid");
				int  uid=-1;
				if(uidStr!=null && !uidStr.equals("")){
					uid=Integer.parseInt(uidStr);
				}
				list=topicdao.findTopicsByUserId(uid);
				request.setAttribute("tlist", list);
				request.getRequestDispatcher("findTopicByUid.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
